package cn.hjh.rpc.check;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import cn.hjh.rpc.define.RPCClientBean;
import cn.hjh.rpc.define.ReplyMode;

/**
 * 临时应答模式下的属性校验类
 * @author jianhua.huang
 * */
@Component
public class TempRPCCheck implements IRPCCheck
{

	@Override
	public boolean isSupport(RPCClientBean bean)
	{
		return ReplyMode.TEMP.name().equals(bean.getReplyMode().name());
	}

	@Override
	public void doCheck(RPCClientBean bean, ConfigurableListableBeanFactory beanFactory)
	{
		String sendQueueName = bean.getSendQueueName();
		String sendQueueKey = bean.getSendQueueKey();
		if(StringUtils.isEmpty(sendQueueName))
		{
			throw new RuntimeException("发送的队列名称为必填项");
		}
		if(StringUtils.isEmpty(sendQueueKey))
		{
			throw new RuntimeException("发送的队列路由key为必填项");
		}
	}

}
